package jin.api;

import jin.model.User;
import jin.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;

/**
 * Created by Administrator on 2016/11/4.
 */
@RestController
@RequestMapping("/user")
public class UserControllerApi {

    @Autowired
    private UserService userService;

    @RequestMapping(path = "/me")
    public ResponseEntity me(Principal principal) {
        User user = null;
        if(principal != null) {
            user = userService.getUserByUsername(principal.getName());
        }

        /* return Optional.ofNullable(user)
                .map(a -> new ResponseEntity<User>(a, HttpStatus.OK))
                .orElseThrow(() -> new UsernameNotFoundException("Username not found"));*/
        if (user != null){

        }
        return null;
    }
}
